
var _path = '/zpmng/';
//url:form add and edit jsp
var _formAddEditUrl="/admin123/coding/a1templatetable/add_edit.jsp";
//url:form add action
var _formAddAction="/admin123/coding/a1templatetable/a1templatetableAjax_addData.action";
//url:form edit action
var _formEditAction="/admin123/coding/a1templatetable/a1templatetableAjax_editData.action";
//url:form remove action
var _formRemoveAction="/admin123/coding/a1templatetable/a1templatetableAjax_removeData.action";
//url:report
var _formReportAction="/admin123/coding/a1templatetable/add_edit.jsp";





var _keyRandom='20161026170402423';
//上个页面通过右击列表 传过来的 id和row; ps:右击模板x列，看模板列列表，自动加载列数，要传模板id找表名
var _prePageListRow = '${paramValues.row[0]}';
_prePageListRow = decodeURI(_prePageListRow);
var _prePageListId = '${paramValues._id[0]}';

//template table foreign key
var _foreignKey = '';
var _primaryKey = 'id';

//add dialog width and height
var _width4AddDialog = '800';
var _height4AddDialog = '600';
if(_width4AddDialog == '' || _width4AddDialog == '0')_width4AddDialog=800;
if(_height4AddDialog == '' || _height4AddDialog == '0')_height4AddDialog=400;
//dialog style, 取代上面的方法
var _isdialog4AddDialog = '0';
var _style4AddDialog = 'width:800px;height:400px;';
if(_style4AddDialog == '')_style4AddDialog='width:800px;height:400px';


/*
	hidden fileds when option has changed
	选择optionId时，filedList是要隐藏的域
	结构如下 ：
	var hiddenFileds = [
		{"optionId":"11","filedList":[{"text":"foreignkey"},{"text":"tablenamesql"}]},
		{"optionId":"12","filedList":[{"text":"tablenamehistorysql"},{"text":"sqlsum"}]}
	];
*/
var hiddenFileds = [{"optionId":"11","filedList":[{"text":"sqlcount"},{"text":"sqlcounthistory"},{"text":"sqlpage"},{"text":"sqlpagehistory"},{"text":"sqlreport"},{"text":"sqlsum"},{"text":"tablenamehistorysql"},{"text":"tablenamesql"},{"text":"foreignkey"},{"text":"sqlprocedure"}]},{"optionId":"12","filedList":[{"text":"beanobject"},{"text":"beanmethod"},{"text":"beanhistorymethod"},{"text":"sqlcount"},{"text":"sqlcounthistory"},{"text":"sqlpage"},{"text":"sqlpagehistory"},{"text":"sqlreport"},{"text":"sqlsum"},{"text":"sqlprocedure"}]},{"optionId":"13","filedList":[{"text":"tablenamehistorysql"},{"text":"tablenamesql"},{"text":"beanobject"},{"text":"beanhistorymethod"},{"text":"beanmethod"}]},{"optionId":"14","filedList":[{"text":"tablealiasname"},{"text":"sqlcount"},{"text":"sqlcounthistory"},{"text":"sqlpage"},{"text":"sqlpagehistory"},{"text":"sqlreport"},{"text":"sqlsum"},{"text":"tablenamehistorysql"},{"text":"tablenamesql"},{"text":"foreignkey"},{"text":"sqlprocedure"}]},{"optionId":"30","filedList":[{"text":"beanmethod"},{"text":"beanhistorymethod"},{"text":"beanobject"},{"text":"tablealiasname"},{"text":"sqlcount"},{"text":"sqlcounthistory"},{"text":"sqlpage"},{"text":"sqlpagehistory"},{"text":"sqlreport"},{"text":"sqlsum"},{"text":"tablenamehistorysql"},{"text":"tablenamesql"},{"text":"foreignkey"}]}]



/**
	页面datagrid控件显示列元素：datagrid.columns
*/
var datagrid_columns = [[{"field":"createdate","width":100,"title":"createDate"},{"field":"createman","width":100,"title":"createMan"},{"field":"modifydate","width":100,"title":"modifyDate"},{"field":"modifyman","width":100,"title":"modifyMan"},{"field":"id","width":100,"title":"ID"},{"field":"keyrandom","width":100,"sortable":"true","title":"KeyRandom"},{"field":"mode","hidden":"true","title":"模式"},{"field":"mode_Str","width":100,"title":"模式"},{"field":"primarykey","width":100,"sortable":"true","title":"PrimaryKey"},{"field":"isdialogAdddialog","hidden":"true","title":"表单打开方式"},{"field":"isdialogAdddialog_Str","width":100,"title":"表单打开方式"},{"field":"tablenameshow","width":100,"title":"tableNameShow"},{"field":"hasaddbtn","width":100,"title":"hasAddBtn"},{"field":"hasdownloadreportbtn","width":100,"title":"hasDownloadReportBtn"},{"field":"haseditbtn","width":100,"title":"hasEditBtn"},{"field":"hashistorybtn","width":100,"title":"hasHistoryBtn"},{"field":"beanmethod","width":100,"title":"beanMethod"},{"field":"beanobject","width":100,"title":"beanObject"},{"field":"beanhistorymethod","width":100,"title":"beanHistoryMethod"},{"field":"tablealiasname","width":100,"title":"tableAliasName"},{"field":"foreignkey","width":100,"title":"foreignKey"},{"field":"hasdelbtn","width":100,"title":"hasDelBtn"},{"field":"hascompanyid","width":100,"title":"hasCompanyId"},{"field":"sqlprocedure","width":100,"title":"sqlProcedure"},{"field":"height4adddialog","width":100,"title":"height4AddDialog"},{"field":"width4adddialog","width":100,"title":"width4AddDialog"},{"field":"chartjson","width":100,"title":"chartJson"},{"field":"chartheight","width":100,"title":"chartHeight"},{"field":"chartwidth","width":100,"title":"chartWidth"},{"field":"interceptaddmethod","width":100,"title":"interceptAddMethod"},{"field":"intercepteditmethod","width":100,"title":"interceptEditMethod"},{"field":"hascheckbox","width":100,"title":"hasCheckbox"},{"field":"datasource","width":100,"title":"dataSource"},{"field":"deleteflag","hidden":"true","title":"删除标志"},{"field":"deleteflag_Str","width":100,"title":"删除标志"},{"field":"interceptobject","width":100,"title":"interceptObject"},{"field":"tablenamesql","width":200,"title":"tableNameSql"},{"field":"tablenamehistorysql","width":200,"title":"tableNameHistorySql"},{"field":"sqlpage","width":200,"title":"sqlPage"},{"field":"sqlcount","width":200,"title":"sqlCount"},{"field":"sqlsum","width":200,"title":"sqlSum"},{"field":"sqlreport","width":200,"title":"sqlReport"},{"field":"sqlpagehistory","width":200,"title":"sqlPageHistory"},{"field":"sqlcounthistory","width":200,"title":"sqlCountHistory"},{"field":"styleAdddialog","width":100,"title":"style_adddialog"},{"field":"createmanId","width":100,"title":"createman_id"},{"field":"modifymanId","width":100,"title":"modifyman_id"},{"field":"companyId","width":100,"title":"company_id"},{"formatter":function(value,rowData,rowIndex){if(typeof(rowData.id) == 'undefined'){return '';};var btn = '';btn += '<a linetail=\"edit\" class=\"editcls\" style=\"height:20px;\" onclick=\"editRow('+rowIndex+')\" href=\"javascript:void(0)\">编辑<\/a>';btn += '<a linetail=\"del\" class=\"delcls\" style=\"height:20px;\" onclick=\"removeRow('+rowIndex+')\" href=\"javascript:void(0)\">删除<\/a>'; return btn;},"field":"opt","width":160,"title":"操作","align":"center"}]]


/**
页面datagrid控件显示列元素：datagrid.frozenColumns
*/
var datagrid_frozenColumns = [[{"field":"tablename","width":100,"title":"tableName"}]]

/**
页面datagrid控件显示列元素：datagrid.toolbarBtns
*/
var datagrid_toolbarBtns = [];
datagrid_toolbarBtns[datagrid_toolbarBtns.length] = {
 id:'toolbarAddBtnId',text:'添加',
 iconCls:'icon-add',
 handler:function(){toolbar_add();}
}



/**
datagrid ，后面在condition.js中init了
*/
var datagrid={
	datagridId:"list",
	datagridUrl:"a1templatetableAjax_queryListBySearch.action",
	datagridObj:{
		/*title:"查询列表",*/
		nowrap:true,
		autoRowHeight:false,
		fit:true,
		columns:datagrid_columns,//datasoure in data.js
		frozenColumns:datagrid_frozenColumns,
		toolbar:datagrid_toolbarBtns,
		rownumbers:true,
		showFooter:true,
		onRowContextMenu:onRowContextMenu
	}
};

var isFirstLoadSuccess = true;
datagrid.datagridObj.onLoadSuccess=function() {
	$('#' + datagrid.datagridId).datagrid('loaded');
	$("#queryBtn_Filter").removeAttr("disabled");
	$('.editcls').linkbutton({plain: true, iconCls: 'icon-edit'});  //给每行后的button加easyui样式
	$('.delcls').linkbutton({plain: true, iconCls: 'icon-remove'});
	//行尾button显示或隐藏
	$("[linetail='edit']").hide();
	authRequestUrl(_formEditAction, function (authResult) {
		if (authResult) {
			$("[linetail='edit']").show();
		}
	});
	$("[linetail='del']").hide();
	authRequestUrl(_formRemoveAction, function (authResult) {
		if (authResult) {
			$("[linetail='del']").show();
		}
	});

	//根据防问权限控制toolbar button显示或隐藏
	if (isFirstLoadSuccess) {
		$('#toolbarAddBtnId').hide();
		authRequestUrl(_formAddAction, function (authResult) {
			if (authResult) {
				$('#toolbarAddBtnId').show();
			}
		});
		isFirstLoadSuccess = false;
	}

};



//添加右击菜单内容
var id;
var rowIndex;
function onRowContextMenu(e, rowIndex1, rowData){
	e.preventDefault();
	rowIndex = rowIndex1;
	var selected=$("#list").datagrid('getRows'); //获取所有行集合对象
	if(selected[rowIndex] == null){return;}
	id = selected[rowIndex].id; //index为当前右键行的索引，指向当前行对象
	$('#rightMenuDiv').menu('show', {
		left:e.pageX,
		top:e.pageY
	});
};




/**
打开AddDialog时，加载默认值
*/
var _defaultValueJOStr = {}


/**
所有列备份一下，一会隐藏了，可以恢复
*/
var _columnDivArray = new Array();
_columnDivArray[_columnDivArray.length] = '#_keyrandom_line';
_columnDivArray[_columnDivArray.length] = '#_mode_line';
_columnDivArray[_columnDivArray.length] = '#_primarykey_line';
_columnDivArray[_columnDivArray.length] = '#_isdialog_adddialog_line';
_columnDivArray[_columnDivArray.length] = '#_tablename_line';
_columnDivArray[_columnDivArray.length] = '#_tablenameshow_line';
_columnDivArray[_columnDivArray.length] = '#_hasaddbtn_line';
_columnDivArray[_columnDivArray.length] = '#_hasdownloadreportbtn_line';
_columnDivArray[_columnDivArray.length] = '#_haseditbtn_line';
_columnDivArray[_columnDivArray.length] = '#_hashistorybtn_line';
_columnDivArray[_columnDivArray.length] = '#_beanmethod_line';
_columnDivArray[_columnDivArray.length] = '#_beanobject_line';
_columnDivArray[_columnDivArray.length] = '#_beanhistorymethod_line';
_columnDivArray[_columnDivArray.length] = '#_tablealiasname_line';
_columnDivArray[_columnDivArray.length] = '#_foreignkey_line';
_columnDivArray[_columnDivArray.length] = '#_hasdelbtn_line';
_columnDivArray[_columnDivArray.length] = '#_hascompanyid_line';
_columnDivArray[_columnDivArray.length] = '#_sqlprocedure_line';
_columnDivArray[_columnDivArray.length] = '#_height4adddialog_line';
_columnDivArray[_columnDivArray.length] = '#_width4adddialog_line';
_columnDivArray[_columnDivArray.length] = '#_chartjson_line';
_columnDivArray[_columnDivArray.length] = '#_chartheight_line';
_columnDivArray[_columnDivArray.length] = '#_chartwidth_line';
_columnDivArray[_columnDivArray.length] = '#_interceptaddmethod_line';
_columnDivArray[_columnDivArray.length] = '#_intercepteditmethod_line';
_columnDivArray[_columnDivArray.length] = '#_hascheckbox_line';
_columnDivArray[_columnDivArray.length] = '#_datasource_line';
_columnDivArray[_columnDivArray.length] = '#_interceptobject_line';
_columnDivArray[_columnDivArray.length] = '#_tablenamesql_line';
_columnDivArray[_columnDivArray.length] = '#_tablenamehistorysql_line';
_columnDivArray[_columnDivArray.length] = '#_sqlpage_line';
_columnDivArray[_columnDivArray.length] = '#_sqlcount_line';
_columnDivArray[_columnDivArray.length] = '#_sqlsum_line';
_columnDivArray[_columnDivArray.length] = '#_sqlreport_line';
_columnDivArray[_columnDivArray.length] = '#_sqlpagehistory_line';
_columnDivArray[_columnDivArray.length] = '#_sqlcounthistory_line';
_columnDivArray[_columnDivArray.length] = '#_style_adddialog_line';


